package managedBean;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;

import ejb.Faq;
import ejb.FaqFacadeRemote;

public class ManterFaq {
	@EJB
	private FaqFacadeRemote tfr;

	
	private Faq currentItem = new Faq();
	private Integer currentRow;
	private Set<Integer> updateRowByAjax = new HashSet<Integer>();
	private List<Faq> listaFaq = new ArrayList<Faq>();

	
	@PostConstruct
	public String carregarFaq(){
		listaFaq = tfr.findAll();
		return null;
	}
	
	public String redirecionaFaq(){
		return "Faq";
	}
	
	public String buscarFaq(){
		listaFaq = tfr.findAll();
		return null;
	}

	public String deletarFaq() {
		tfr.delete(currentItem);
		carregarFaq();
		clean();
		return null;
	}

	
	public String salvarFaq() {
		currentItem.setId(1);
		tfr.save(currentItem);		
		carregarFaq();
		clean();
		return null;
	}
	
	
	public String updateFaq() {
		tfr.update(currentItem);
		buscarFaq();
		clean();
		return null;
	}

	public String clean() {
		currentItem = new Faq();		
		return null;
	}

	public Faq getCurrentItem() {
		return currentItem;
	}

	public void setCurrentItem(Faq currentItem) {
		this.currentItem = currentItem;
	}

	public Integer getCurrentRow() {
		return currentRow;
	}

	public void setCurrentRow(Integer currentRow) {
		this.currentRow = currentRow;
	}

	public Set<Integer> getUpdateRowByAjax() {
		return updateRowByAjax;
	}

	public void setUpdateRowByAjax(Set<Integer> updateRowByAjax) {
		this.updateRowByAjax = updateRowByAjax;
	}

	public List<Faq> getListaFaq() {
		return listaFaq;
	}

	public void setListaFaq(List<Faq> listaFaq) {
		this.listaFaq = listaFaq;
	}
	
	public String verificaSenha(){
		return null;
	}

	
}